package com.springinaction.ch03.scope;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.context.annotation.ScopedProxyMode;
import org.springframework.stereotype.Component;
import org.springframework.web.context.WebApplicationContext;

@Component
/**
 * value 作用域
 * web WebApplicationContext.SCOPE_SESSION  session
 * web WebApplicationContext.SCOPE_REQUEST  request
 *
 *proxyMode  处理注入bean时 产生bean的代理
 *
 * 对于注入类
 * ScopedProxyMode.TARGET_CLASS
 * 对于注入接口
 * ScopedProxyMode.INTERFACES
 */
@Scope(
        value = WebApplicationContext.SCOPE_SESSION,
        proxyMode = ScopedProxyMode.INTERFACES
)
public class StoreService {
    private ShopingCart shopingCart;

    @Autowired
    public StoreService(ShopingCart shopingCart) {
        this.shopingCart = shopingCart;
    }
}
